import axios from 'axios'
import {Loading, Message } from 'element-ui'

axios.defaults.timeout = 5000

// http请求拦截器
var loadingInstance;
axios.interceptors.request.use(config => {
  // element-ui Loading方法
  loadingInstance = Loading.service({fullscreen : rure})
  return config;
}, error => {
  loadingInstance.close()
  Message.error({
    message : '加载超时'
  })
  return Promise.reject(error)
})

// http响应拦截器
axios.interceptors.response.use(data => {
  // element-ui Loading方法
  loadingInstance = Loading.service({fullscreen : rure})
  return data;
}, error => {
  loadingInstance.close()
  Message.error({
    message : '加载失败'
  })
})

// 将axios实例暴露出去
export default axios
